﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IdentityModel.Selectors;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Header
{
	public class MyCustomValidator : UserNamePasswordValidator
	{
		private IDbConnection connection;

		/// <summary>
		/// Instance new object
		/// </summary>
		/// <param name="connection"></param>
		public MyCustomValidator(IDbConnection connection)
		{
			this.connection = connection;
		}

		/// <summary>
		/// This function is invoked every time request recived
		/// </summary>
		/// <param name="userName"></param>
		/// <param name="password"></param>
		public override void Validate(string userName, string password)
		{
			connection.Open();

			//var  cmd = connection.CreateCommand() as MySqlCommand;

			var cmd = connection.CreateCommand();
			cmd.CommandType = CommandType.StoredProcedure;

			var param = cmd.CreateParameter();
			param.ParameterName = "str";
			param.Value = "thanh";

			cmd.CommandText = "GetOne";
			var ret = cmd.ExecuteScalar();

			Debug.Write(ret);
			connection.Close();

			
		}
	}
}
